package com.co.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTextField;
import javax.swing.WindowConstants;

import com.co.controller.ObraSocialPageController;
import com.co.utils.Constants;
import com.co.utils.JPage;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class ObraSocialPage extends JPage {

	// Components
	private JMenuBar jMenuBar1;
	private JButton jButtonSave;
	private JMenuItem jMenuItem2;
	private JMenuItem jMenuItem1;
	private JMenu jMenu1;
	private String title = "Paciente";
	private JTextField jTextFielCodigo;
	private JTextField jTextFieldNombre;
	private JLabel jLabel1;
	private JLabel jLabelNombre;
	private JLabel jLabelCodigo;

	// Controller
	private ObraSocialPageController obraSocialPageController;

	// Constructor
	public ObraSocialPage() {
		super();
		this.id = Constants.OBRA_SOCIAL_PAGE;

		// Inicializo el controlador.
		obraSocialPageController = ObraSocialPageController.getInstance();
		obraSocialPageController.configure(this.getId(), this);

		// Initialize GUI
		initGUI();
	}

	// SINGLETON
	private static ObraSocialPage obraSocialPageInstance;

	public static ObraSocialPage getInstance() {
		if (obraSocialPageInstance == null) {
			obraSocialPageInstance = new ObraSocialPage();
		}
		return obraSocialPageInstance;
	}

	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jMenuBar1 = new JMenuBar();
				setJMenuBar(jMenuBar1);
				jMenuBar1.setPreferredSize(new java.awt.Dimension(384, 16));
				{
					jMenu1 = new JMenu();
					jMenuBar1.add(jMenu1);
					jMenu1.setText("Menu");
					{
						jMenuItem1 = new JMenuItem();
						jMenu1.add(jMenuItem1);
						jMenuItem1.setText("Principal");
						jMenuItem1.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out
										.println("jMenuItem1.actionPerformed, event="
												+ evt);
							}
						});
					}
					{
						jMenuItem2 = new JMenuItem();
						jMenu1.add(jMenuItem2);
						jMenuItem2.setText("Salir");
						jMenuItem2.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								System.out
										.println("jMenuItem2.actionPerformed, event="
												+ evt);
								System.exit(0);
							}
						});
					}
				}
			}
			pack();
			this.setTitle("Consultorios Odontologicos - " + this.title);
			this.setSize(1024, 453);
			this.setExtendedState(MAXIMIZED_BOTH);
			{
				jLabelCodigo = new JLabel();
				getContentPane().add(jLabelCodigo);
				jLabelCodigo.setText("Codigo:");
				jLabelCodigo.setBounds(60, 39, 60, 30);
			}
			{
				jLabelNombre = new JLabel();
				getContentPane().add(jLabelNombre);
				jLabelNombre.setText("Nombre:");

				jLabelNombre.setBounds(61, 126, 63, 28);
			}
			{
				jTextFielCodigo = new JTextField();
				getContentPane().add(jTextFielCodigo);
				jTextFielCodigo.setBounds(140, 42, 63, 28);
			}
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setBounds(140, 84, 63, 28);
			}
			{
				jTextFieldNombre = new JTextField();
				getContentPane().add(jTextFieldNombre);
				jTextFieldNombre.setBounds(140, 126, 63, 28);
			}
			{
				jButtonSave = new JButton();
				getContentPane().add(jButtonSave);
				jButtonSave.setText("Guardar");
				jButtonSave.setBounds(322, 56, 84, 28);
				jButtonSave.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out
								.println("jButtonSave.actionPerformed, event="
										+ evt);
						obraSocialPageController.saveObraSocial(
								jTextFielCodigo.getText(),
								jTextFieldNombre.getText());
					}
				});
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
